-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		velox
-- Create date: 2014-11-17
-- Description:	get sow basic information, sow bit id, pigpenname,pigtype
-- =============================================
IF exists (select * from sysobjects where id = object_id('dbo.GetSowBasicInfo_Proce'))
	drop PROCEDURE "dbo"."GetSowBasicInfo_Proce"
Go
CREATE PROCEDURE GetSowBasicInfo_Proce 
	@SowId uniqueidentifier, 
	@HoggeryId int
AS
BEGIN
	SET NOCOUNT ON;

	select s.BitID,pp.CustomizeID,pb.TypeName,s.FanQingCount,ps.PropagateStateOrder from Sow s
	left join PigPen pp on s.PigPenID=pp.PigPenID
	left join PigBreed pb on s.TypeID=pb.TypeID
	left join PropagateState ps on ps.StateID=s.PropagateStateID
	where s.SowID=@SowId and s.HoggeryID=@HoggeryId and s.IsInFarm=1
END
GO
